//
//  NSString+Size.m
//  CNTVPandaChannel
//
//  Created by fenggaowei on 15/12/9.
//  Copyright © 2015年 brilliance. All rights reserved.
//

#import "NSString+Size.h"

@implementation NSString (Size)


//返回字符串的size
- (CGSize)stringSizeWithMaxSize:(CGSize)maxSize withFont:(UIFont *)font
{
    NSDictionary *attrs = @{NSFontAttributeName : font};
    CGSize titleSize= [self boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size;
    return titleSize;
}


//返回字符串的高
- (CGFloat)stringHeightWithMaxSize:(CGSize)maxSize withFont:(UIFont *)font
{
    return [self stringSizeWithMaxSize:maxSize withFont:font].height;
}

@end
